package cn.luischen.exception;

import cn.luischen.utils.APIResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.MessageFormat;

import static org.junit.Assert.*;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
import org.junit.Rule;
import org.junit.runner.RunWith;
import org.junit.rules.ExpectedException;
import org.junit.Test;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.stubbing.Answer;
import java.lang.reflect.Method;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.TypeReference;
import com.alibaba.fastjson.parser.ParserConfig;
import java.util.Map;
import java.util.List;
import com.unitspirit.runtime.*;

/**
 * The class contains tests for the class cn.luischen.exception.BusinessException.
 *
 * @generatedBy UnitSpirit CreateTemplateTestFile4
 * @version 1.0.9.11 
 */
@PowerMockIgnore({ "javax.management.*" })
public class BusinessException_withErrorCode_WGTest {
	@Rule
	public ExpectedException unitspirit_thrown = ExpectedException.none();

	/**
	 * 测试方法初始化.
	 * 
	 * @throws Exception 
	 *         if the initialization fails for some reason 
	 *  
	 * @generatedBy UnitSpirit at 2021-12-06 21:50:26
	 */
	@org.junit.Before
	public void setUp() throws Exception {
		try {
			GlobalUnitInit.init();
			MockitoAnnotations.initMocks(this);
			ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}

	/**
	 * @date 2021-12-06 21:50:26
	 * @see cn.luischen.exception.BusinessException#withErrorCode
	 * @category auto generate by UnitSpirit  
	 */
	@Test
	public void test_withErrorCode_20211109_110317_805_1_01() throws Throwable {
		String String_p_0 = "用户名不存在或密码错误";
		//返回值定义 
		String result_expected = "{\"@type\":\"cn.luischen.exception.BusinessException\",\"errorCode\":\"用户名不存在或密码错误\",\"stackTrace\":[{\"fileName\":\"BusinessException.java\",\"methodName\":\"withErrorCode\",\"lineNumber\":53},{\"fileName\":\"UserServiceImpl.java\",\"methodName\":\"login\",\"lineNumber\":63},{\"fileName\":\"<generated>\",\"methodName\":\"invoke\",\"lineNumber\":-1},{\"fileName\":\"MethodProxy.java\",\"methodName\":\"invoke\",\"lineNumber\":204},{\"fileName\":\"CglibAopProxy.java\",\"methodName\":\"intercept\",\"lineNumber\":685},{\"fileName\":\"<generated>\",\"methodName\":\"login\",\"lineNumber\":-1},{\"fileName\":\"AuthController.java\",\"methodName\":\"toLogin\",\"lineNumber\":80},{\"fileName\":\"<generated>\",\"methodName\":\"invoke\",\"lineNumber\":-1},{\"fileName\":\"MethodProxy.java\",\"methodName\":\"invoke\",\"lineNumber\":204},{\"fileName\":\"CglibAopProxy.java\",\"methodName\":\"invokeJoinpoint\",\"lineNumber\":747},{\"fileName\":\"ReflectiveMethodInvocation.java\",\"methodName\":\"proceed\",\"lineNumber\":163},{\"fileName\":\"MethodBeforeAdviceInterceptor.java\",\"methodName\":\"invoke\",\"lineNumber\":52},{\"fileName\":\"ReflectiveMethodInvocation.java\",\"methodName\":\"proceed\",\"lineNumber\":185},{\"fileName\":\"AfterReturningAdviceInterceptor.java\",\"methodName\":\"invoke\",\"lineNumber\":52},{\"fileName\":\"ReflectiveMethodInvocation.java\",\"methodName\":\"proceed\",\"lineNumber\":185},{\"fileName\":\"ExposeInvocationInterceptor.java\",\"methodName\":\"invoke\",\"lineNumber\":92},{\"fileName\":\"ReflectiveMethodInvocation.java\",\"methodName\":\"proceed\",\"lineNumber\":185},{\"fileName\":\"CglibAopProxy.java\",\"methodName\":\"intercept\",\"lineNumber\":689},{\"fileName\":\"<generated>\",\"methodName\":\"toLogin\",\"lineNumber\":-1},{\"fileName\":\"NativeMethodAccessorImpl.java\",\"methodName\":\"invoke0\",\"lineNumber\":-2},{\"fileName\":\"NativeMethodAccessorImpl.java\",\"methodName\":\"invoke\",\"lineNumber\":62},{\"fileName\":\"DelegatingMethodAccessorImpl.java\",\"methodName\":\"invoke\",\"lineNumber\":43},{\"fileName\":\"Method.java\",\"methodName\":\"invoke\",\"lineNumber\":498},{\"fileName\":\"InvocableHandlerMethod.java\",\"methodName\":\"doInvoke\",\"lineNumber\":209},{\"fileName\":\"InvocableHandlerMethod.java\",\"methodName\":\"invokeForRequest\",\"lineNumber\":136},{\"fileName\":\"ServletInvocableHandlerMethod.java\",\"methodName\":\"invokeAndHandle\",\"lineNumber\":102},{\"fileName\":\"RequestMappingHandlerAdapter.java\",\"methodName\":\"invokeHandlerMethod\",\"lineNumber\":877},{\"fileName\":\"RequestMappingHandlerAdapter.java\",\"methodName\":\"handleInternal\",\"lineNumber\":783},{\"fileName\":\"AbstractHandlerMethodAdapter.java\",\"methodName\":\"handle\",\"lineNumber\":87},{\"fileName\":\"DispatcherServlet.java\",\"methodName\":\"doDispatch\",\"lineNumber\":991},{\"fileName\":\"DispatcherServlet.java\",\"methodName\":\"doService\",\"lineNumber\":925},{\"fileName\":\"FrameworkServlet.java\",\"methodName\":\"processRequest\",\"lineNumber\":974},{\"fileName\":\"FrameworkServlet.java\",\"methodName\":\"doPost\",\"lineNumber\":877},{\"fileName\":\"HttpServlet.java\",\"methodName\":\"service\",\"lineNumber\":661},{\"fileName\":\"FrameworkServlet.java\",\"methodName\":\"service\",\"lineNumber\":851},{\"fileName\":\"HttpServlet.java\",\"methodName\":\"service\",\"lineNumber\":742},{\"fileName\":\"ApplicationFilterChain.java\",\"methodName\":\"internalDoFilter\",\"lineNumber\":231},{\"fileName\":\"ApplicationFilterChain.java\",\"methodName\":\"doFilter\",\"lineNumber\":166},{\"fileName\":\"WsFilter.java\",\"methodName\":\"doFilter\",\"lineNumber\":52},{\"fileName\":\"ApplicationFilterChain.java\",\"methodName\":\"internalDoFilter\",\"lineNumber\":193},{\"fileName\":\"ApplicationFilterChain.java\",\"methodName\":\"doFilter\",\"lineNumber\":166},{\"fileName\":\"WebStatFilter.java\",\"methodName\":\"doFilter\",\"lineNumber\":123},{\"fileName\":\"ApplicationFilterChain.java\",\"methodName\":\"internalDoFilter\",\"lineNumber\":193},{\"fileName\":\"ApplicationFilterChain.java\",\"methodName\":\"doFilter\",\"lineNumber\":166},{\"fileName\":\"RequestContextFilter.java\",\"methodName\":\"doFilterInternal\",\"lineNumber\":99},{\"fileName\":\"OncePerRequestFilter.java\",\"methodName\":\"doFilter\",\"lineNumber\":107},{\"fileName\":\"ApplicationFilterChain.java\",\"methodName\":\"internalDoFilter\",\"lineNumber\":193},{\"fileName\":\"ApplicationFilterChain.java\",\"methodName\":\"doFilter\",\"lineNumber\":166},{\"fileName\":\"HttpPutFormContentFilter.java\",\"methodName\":\"doFilterInternal\",\"lineNumber\":109},{\"fileName\":\"OncePerRequestFilter.java\",\"methodName\":\"doFilter\",\"lineNumber\":107},{\"fileName\":\"ApplicationFilterChain.java\",\"methodName\":\"internalDoFilter\",\"lineNumber\":193},{\"fileName\":\"ApplicationFilterChain.java\",\"methodName\":\"doFilter\",\"lineNumber\":166},{\"fileName\":\"HiddenHttpMethodFilter.java\",\"methodName\":\"doFilterInternal\",\"lineNumber\":81},{\"fileName\":\"OncePerRequestFilter.java\",\"methodName\":\"doFilter\",\"lineNumber\":107},{\"fileName\":\"ApplicationFilterChain.java\",\"methodName\":\"internalDoFilter\",\"lineNumber\":193},{\"fileName\":\"ApplicationFilterChain.java\",\"methodName\":\"doFilter\",\"lineNumber\":166},{\"fileName\":\"CharacterEncodingFilter.java\",\"methodName\":\"doFilterInternal\",\"lineNumber\":200},{\"fileName\":\"OncePerRequestFilter.java\",\"methodName\":\"doFilter\",\"lineNumber\":107},{\"fileName\":\"ApplicationFilterChain.java\",\"methodName\":\"internalDoFilter\",\"lineNumber\":193},{\"fileName\":\"ApplicationFilterChain.java\",\"methodName\":\"doFilter\",\"lineNumber\":166},{\"fileName\":\"StandardWrapperValve.java\",\"methodName\":\"invoke\",\"lineNumber\":198},{\"fileName\":\"StandardContextValve.java\",\"methodName\":\"invoke\",\"lineNumber\":96},{\"fileName\":\"AuthenticatorBase.java\",\"methodName\":\"invoke\",\"lineNumber\":496},{\"fileName\":\"StandardHostValve.java\",\"methodName\":\"invoke\",\"lineNumber\":140},{\"fileName\":\"ErrorReportValve.java\",\"methodName\":\"invoke\",\"lineNumber\":81},{\"fileName\":\"StandardEngineValve.java\",\"methodName\":\"invoke\",\"lineNumber\":87},{\"fileName\":\"CoyoteAdapter.java\",\"methodName\":\"service\",\"lineNumber\":342},{\"fileName\":\"Http11Processor.java\",\"methodName\":\"service\",\"lineNumber\":803},{\"fileName\":\"AbstractProcessorLight.java\",\"methodName\":\"process\",\"lineNumber\":66},{\"fileName\":\"AbstractProtocol.java\",\"methodName\":\"process\",\"lineNumber\":790},{\"fileName\":\"NioEndpoint.java\",\"methodName\":\"doRun\",\"lineNumber\":1459},{\"fileName\":\"SocketProcessorBase.java\",\"methodName\":\"run\",\"lineNumber\":49},{\"fileName\":\"ThreadPoolExecutor.java\",\"methodName\":\"runWorker\",\"lineNumber\":1149},{\"fileName\":\"ThreadPoolExecutor.java\",\"methodName\":\"run\",\"lineNumber\":624},{\"fileName\":\"TaskThread.java\",\"methodName\":\"run\",\"lineNumber\":61},{\"fileName\":\"Thread.java\",\"methodName\":\"run\",\"lineNumber\":748}],\"errorMessageArguments\":[]}";

		//Not Support: access:1
		//Not Support: access:4

		cn.luischen.exception.BusinessException unitspirit_result = cn.luischen.exception.BusinessException
				.withErrorCode(String_p_0);
		assertEquals(
				UnitSpiritFastJsonUtil
						.getDataWithOutStackTrace(result_expected),
				UnitSpiritFastJsonUtil
						.getJsonStringWithOutStackTrace(unitspirit_result));
	}

}
